<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 200px;
        height: 200px;
        background-color: pink;
        padding: 10px;
      }
    </style>
  </head>
  <body>
    <div class="box" style="width: 200px"></div>
    <script>
      var box = document.querySelector('.box');
      console.log(box.offsetWidth); //220
      console.log(box.style.width); //200px    只能获取style里的数据
    </script>
  </body>
</html>
